package com.ftg.exam.manage.mapper;

import com.ftg.exam.manage.pojo.OneChoice;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author zwl
 * 单项选择管理
 * Created on 2019/8/13 10:30
 */
@Mapper
public interface OneChoiceMapper {
    /**
     * 显示单选题
     * @return
     */
    @Select("select * from one_choice")
    public List<OneChoice> showall(OneChoice pageH);
    /**
     * 选择题库难度下拉框
     * @return
     */
    @Select("select difficulty from Difficulties")
    public List<OneChoice> showDifficulty();

    /**
     * 更新试题操作
     * @param oneChoice
     * @return
     */
    @Update("update one_choice set difficulty=#{difficulty},question=#{question},a=#{a},b=#{b},c=#{c},d=#{d},answer=#{answer},analysis=#{analysis} where id=#{id}")
    public int update(OneChoice oneChoice);

    /**
     * 删除试题操作
     * @param id
     * @return
     */
    @Delete("delete from one_choice where id=#{id}")
    public int delete(String id);

    /**
     * 添加试题操作
     * @param oneChoice
     * @return
     */
    @Insert("insert into one_choice(difficulty,question,a,b,c,d,answer,analysis) values(#{difficulty},#{question},#{a},#{b},#{c},#{d},#{answer},#{analysis})")
    public int save(OneChoice oneChoice);
    /**
     * 查询试题操作
     * @return
     */
    @Select("select * from one_choice where question like \"%\"#{write}\"%\"")
    List<OneChoice> showone(OneChoice pageH);
}
